package com.gitee.cnlongdb.basic.entity.backups;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gitee.cnlongdb.basic.entity.matchingrule.MatchingReadWrite;

/**
 * 系统名称：财务中心
 * 模块名称：
 × 模块描述：数据同步或备份实体类
 × 功能列表：
 × 模块作者：ZOUYONG
 × 开发时间：2018年12月25日 上午10:54:35
 × 模块路径：com.gitee.cnlongdb.basic.entity.backups.LongdbBackupsEntity
 */
public class LongdbBackupsEntity implements Serializable {

	// 序列化ID
	private static final long serialVersionUID = 1L;
	
	// 操作类型(增、删、改)
	private String operType;
	
	// 操作的数据库名称
	private String dataBaseName;
	
	// 操作的表名称
	private String tableName;
	
	// 操作的方法名称
	private String methodName;
	
	// 操作方法的参数类型
	private Class[] paramClas;
	
	// 操作方法的参数值列表
	private Object[] paramObject;
	
	// 操作时间
	private Date operDate;
	
	// 操作结果
	private boolean operStatus = false;
	
	// 操作结果描述
	private String operMessage;
	
	// 已备份的从库数据列表
	private List<MatchingReadWrite> matchingList = new ArrayList<MatchingReadWrite>();

	public String getOperType() {
		return operType;
	}

	public void setOperType(String operType) {
		this.operType = operType;
	}

	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public Date getOperDate() {
		return operDate;
	}

	public void setOperDate(Date operDate) {
		this.operDate = operDate;
	}

	public boolean isOperStatus() {
		return operStatus;
	}

	public void setOperStatus(boolean operStatus) {
		this.operStatus = operStatus;
	}

	public String getOperMessage() {
		return operMessage;
	}

	public void setOperMessage(String operMessage) {
		this.operMessage = operMessage;
	}

	public String getDataBaseName() {
		return dataBaseName;
	}

	public void setDataBaseName(String dataBaseName) {
		this.dataBaseName = dataBaseName;
	}

	public String getMethodName() {
		return methodName;
	}

	public void setMethodName(String methodName) {
		this.methodName = methodName;
	}

	public Class[] getParamClas() {
		return paramClas;
	}

	public void setParamClas(Class[] paramClas) {
		this.paramClas = paramClas;
	}

	public Object[] getParamObject() {
		if(null != this.paramClas && this.paramClas.length > 0) {
			boolean status = true;
			for(int i=0; i<paramObject.length; i++) {
				if(!(paramObject[i] instanceof JSONObject)) {
					status = false;
				}
			}
			if(status) {
				Object[] objAry = new Object[this.paramClas.length];
				for(int i=0; i<this.paramClas.length; i++) {
					Class cls = this.paramClas[i];
					JSONObject object = (JSONObject) paramObject[i];
					objAry[i] = JSON.parseObject(object.toJSONString(), cls);
				}
				return objAry;
			}
		}
		return paramObject;
	}

	public void setParamObject(Object[] paramObject) {
		this.paramObject = paramObject;
	}

	public List<MatchingReadWrite> getMatchingList() {
		return matchingList;
	}

	public void setMatchingList(List<MatchingReadWrite> matchingList) {
		this.matchingList = matchingList;
	}

}
